
#define VTRY try

#define VCATCHONLY catch(std::string Exception) {	\
	printf("Exception:%s\n",Exception.c_str());		\
	}

#define VCATCH catch(std::string ExceptionStr) {	\
	char exStr[512] = {0}; \
	sprintf(exStr, "%s\n", ExceptionStr.c_str()); \
	printf("Exception:%s\n",ExceptionStr.c_str());	\
	OutputDebugString(exStr); \
	cout<<ExceptionStr.c_str()<<endl; \
	}

#define VTHROW(message) throw std::string(message);

#define VTHROW_INTERNALERROR(errorMessage) {	\
	char __ib[1024] = {'\0'};					\
	sprintf_s(__ib, 1024,						\
	"\nInternal Error: (File: %s Line: %i) %s",	\
	__FILE__, (__LINE__), errorMessage);		\
	throw std::string(__ib);					\
	}

#define STATUS(message){  }

#define FOREACH(elementType, elementVariable, elementVector) for( \
	std::vector<elementType>::iterator elementVariable = elementVector.begin(); \
	elementVariable != elementVector.end(); \
	elementVariable++)

#define DEBUG_PRINT(vsfmt,vsdata) { \
	char vsstrbuff[512] = {0}; \
	char vsstrfina[512] = {0}; \
		sprintf(vsstrbuff, vsfmt, vsdata); \
		sprintf(vsstrfina, "%s\n", vsstrbuff); \
	OutputDebugString(vsstrfina); \
	}

#define byte char

#ifndef GLOBAL
#define GLOBAL

#include <stdio.h>
#include <stdarg.h>
#include <string>

struct tException
{
	std::string Message;
	tException() {

		Message = "None";
	}
	tException(const char* messageFmt, ...) {

		char Buffer[1024];
		va_list args;
		va_start (args, messageFmt);
		vsprintf (Buffer,messageFmt, args);
		va_end (args);

		Message = Buffer;
	}
	tException(const char *pFilename, const int line, const char* messageFmt, ...) {

		char Buffer[1024];
		va_list args;
		va_start (args, messageFmt);
		vsprintf (Buffer,messageFmt, args);
		va_end (args);

		char final[1536];
		sprintf(final, "File:%s\nLine:%i\nMessage:%s", pFilename ? pFilename : "Unknown", line, Buffer); 
		Message = final;
	}

	static void GetMessage(tException* pException, std::string& message) {

		char Buffer[1024] = {0};
		sprintf(Buffer, "ERROR:\nLine:%i\nFile:%s\nDetails:%s\n", __LINE__, __FILE__, pException ? pException->Message.c_str() : "Incorrect usage\n");
		message = Buffer;
	}
};

#endif